package com.java.wzb.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import com.java.common.pojo.Dept;
import com.java.common.pojo.Emp;
import com.java.common.pojo.Job;
import com.java.wzb.dao.IEmpDAO;

public class EmpServiceImpl{
	private IEmpDAO empDao;
	public IEmpDAO getEmpDao() {
		return empDao;
	}

	public void setEmpDao(IEmpDAO empDao) {
		this.empDao = empDao;
	}

	public List<Emp> FilterEmpListByJobs(List<Emp> empList, String[] jobs) {
		empDao.filterEmpListByJobs(empList, jobs);
		return empList;
	}

	public List<Emp> FilterEmpListByPermissions(List<Emp> empList,
			String[] permissions) {
		empDao.filterEmpListByPermissions(empList, permissions);
		return empList;
	}

	public Dept GetManEmp(Emp emp, String empId) {
		empDao.getManEmp(emp, empId);
		Dept dept = emp.getDept();
		return dept;
	}

	@SuppressWarnings("unchecked")
	public Set<Emp> GetManEmps(Emp emp) {
		empDao.getManEmps(emp);
		return (Set<Emp>) emp;
	}

	public int GetManEmpsCount(Emp emp) {
		int count = 0;
		empDao.getManEmpsCount(emp);
		ArrayList<Emp> empcount = new ArrayList<Emp>();
		for(int i = 0;i<empcount.size();i++){
			count++;
		}
		return count;
	}

	public List<Emp> GetSubEmpsByCondition(String[] conditions,
			String orderBy, int Start, int count) {
		empDao.getSubEmpsByCondition(conditions, orderBy, Start, count);
		ArrayList<Emp> emp = new ArrayList<Emp>();
		return emp;
	}

	public List<Emp> GetSubManEmps(Emp emp, String[] conditions,
			String orderBy, int start, int count) {
		empDao.getSubManEmps(emp, conditions, orderBy, start, count);
		return null;
	}

	public boolean NewEmp(Emp emp) {
		return empDao.newEmp(emp);
	}

	public boolean RemoveEmp(String empId) {
		boolean flag = false;
		empDao.removeEmp(empId);
		if(empId.equals(null)!=false&&"".equals(empId)!=false){
			flag = true;
		}
		return flag;
	}

	public boolean RemoveManEmp(Emp emp, String empId) {
		empDao.removeManEmp(emp, empId);
		return true;
	}

	public boolean UpdateEmp(Emp emp) {
		empDao.updateEmp(emp);
		return true;
	}

	public boolean UpdateEmpJob(Set<Job> empJobs) {
		empDao.updateEmpJob(empJobs);
		return true;
	}

	public boolean UpdateManEmp(Emp emp, Emp manEmp) {
		empDao.updateManEmp(emp, manEmp);
		return true;
	}
	
//	public static void main(String[] args) {
//		ApplicationContext ac = new ClassPathXmlApplicationContext("appWZBContext.xml");
//		Test t = (Test) ac.getBean("test");
//		t.testNewEmp(new Emp());
//	}
}
